﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGridLayout>
#include <QMessageBox>
#include <QScreen>
#include "../CheckInfor/DataBase/keywordlib.h"
#include "../CheckTool/filefilter.h"
#include "../CheckInfor/fileinfor.h"
#include "../CheckTool/maintool.h"
#include "../CheckTool/filetool.h"
#include "../CheckInfor/maininfor.h"
#include "securitywidget.h"
#include "normalwidget.h"
#include "hardwidget.h"
#include "deepwidget.h"
#include "../CheckTool/reporttool.h"
#include<QProcess>
#define INSTALLMODCMD "deepin-terminal -e 'bash ../install_mods.sh %1'"



//static int Statusnum=8; //状态栏项目个数

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    Init_Ui();
    LoadConfig();
    Yzty::FileCondtionFlag=false;
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::Init_Ui(){

    ui->stackedWidget->setCurrentIndex(0);

    _toolBoxs=QVector<ToolBox*>{ui->normaltoolBox,ui->securitytoolBox,
            ui->filetoolBox,ui->deeptoolBox,ui->virmachinetoolBox,ui->emailtoolBox,ui->hardtoolBox,ui->reporttoolBox};

    _lcdtimes=QVector<QLCDNumber*>{ui->lcdNumber,ui->lcdNumber_2,ui->lcdNumber_3,
            ui->lcdNumber_4,ui->lcdNumber_5,ui->lcdNumber_6,ui->lcdNumber_7,ui->lcdNumber_8};

    _processbars=QVector<QProgressBar*>{ui->progressBar,ui->progressBar_2,ui->progressBar_3,
            ui->progressBar_4,ui->progressBar_5,ui->progressBar_6,ui->progressBar_7,ui->progressBar_8};

    _checktools=QVector<QPushButton*>{ui->normal_button,ui->security_button,ui->file_button,
                                         ui->deep_button,ui->virmachine_button,ui->email_button,ui->hard_button,ui->report_button};

    _timeids=QVector<int>(int(Yzty::ToolCode::Total),-1);                   //计时器ＩＤ

    _counts=std::vector<std::atomic<int>>(int(Yzty::ToolCode::Total));        //任务计数器

    _models=QVector<int>(int(Yzty::ToolCode::Total));

    _times=QVector<QTime>(int(Yzty::ToolCode::Total));

    //功能触发
    for(int i=0;i<_checktools.size();i++)
        connect(_checktools[i],&QPushButton::clicked,[this,i](){
            this->CheckButton_CLick(i);
        });

    //时间显示
    for(int i=0;i<_processbars.size();i++){
        _lcdtimes[i]->setDigitCount(5);
        _lcdtimes[i]->setMode(QLCDNumber::Dec);
        _lcdtimes[i]->display("00:00");
        _processbars[i]->setValue(0);
    }

    _isrun=QVector<bool>(int(Yzty::ToolCode::Total),false);
    _isfinish=QVector<bool>(int(Yzty::ToolCode::Total),false);

    connect(MainTool::GetInstance(),&MainTool::Finish,this,&MainWindow::AcceptFinish);

    connect(MainTool::GetInstance(),&MainTool::FileFinish,[this](int ,int fnum,int total){
        static std::mutex qmutex;
        qmutex.lock();
        _models[int(Yzty::ToolCode::File)]=total;
        _counts[int(Yzty::ToolCode::File)]=fnum;
//        ui->filewidget->UpDatecnts();
        qmutex.unlock();
    });

    _filterdialog=new FileFilterDialog(Yzty::ToolCode::File,this);
    _emaildialog=new FileFilterDialog(Yzty::ToolCode::Email,this);
    _virmachinedialog= new FileFilterDialog(Yzty::ToolCode::VirMachine,this);
    _deepdialog=new FileFilterDialog(Yzty::ToolCode::Deep,this);

    connect(ui->file_config_button,&QPushButton::clicked,this,&MainWindow::FileCondtionDialog);
    connect(ui->deep_config_button,&QPushButton::clicked,this,&MainWindow::DeepConditonDialog);
    connect(ui->email_config_button,&QPushButton::clicked,this,&MainWindow::EmailCondtionDialog);
    connect(ui->virmachine_config_button,&QPushButton::clicked,this,&MainWindow::VirCondtionDialog);



    MainTool::GetInstance()->StatusBarInforGetLoading();

    Init_StatusBar(100);

    //获取每个功能模块的数量，用于计算进度条
    for(int i=0;i<int(Yzty::ToolCode::Total);i++)
        _models[i]=0;
    _models[int(Yzty::ToolCode::Hard)]=HardWidget::ShowTools.size();
//    _modes[int(Yzty::ToolCode::Deep)]=DeepWidget::.size();
    _models[int(Yzty::ToolCode::Normal)]=NormalWidget::ShowTools.size();
    _models[int(Yzty::ToolCode::Security)]=SecurityWidget::ShowTools.size();


    //单项检查
    _ListWidgetMenu=new QMenu(this);
    QAction* singleCheck=new QAction("单项检查",_ListWidgetMenu);
    _ListWidgetActions.push_back(singleCheck);
    connect(singleCheck,&QAction::triggered,[this](){
        if(!_isrun[ui->stackedWidget->currentIndex()]){ //如果没有点击一键检查
            this->SingleCheck(ui->stackedWidget->currentIndex(),this->_current.data(Qt::UserRole).toInt());
        }
    });
    _ListWidgetMenu->addAction(singleCheck);
}

void MainWindow::LoadConfig(){

    QTextStream& fstream=Yzty::GetTextSteam(Yzty::CONFIGPATH);
    QStringList items=fstream.readAll().split('#');
    items.removeFirst();
    auto&& head=Yzty::ConfigParse_Head(items);      //解析头部

    int models=head["models"].toInt();          //模块个数

    this->_toolButtons=QVector<QToolButton*>(models);
    _modelListWidget.resize(models);
    _models.resize(models);
    _tool_items_nums.resize(models);
    _tool_items.resize(models);
    _tool_items_labels.resize(models);

    QStringList modelspaths=head["mpaths"].split(' ');   //模块路径

    for(int i=0;i<models;i++){

        QTextStream& fstream=Yzty::GetTextSteam(modelspaths[i]);
        QStringList items=fstream.readAll().split('#');
        items.removeFirst();
        auto&& head=Yzty::ConfigParse_Head(items);
        auto&& body=Yzty::ConfigParse_Body(items);

        //加入ToolBar
        QString text=head["Title"];
        _toolButtons[i]=new QToolButton(this);
        _toolButtons[i]->setText(text);
        ui->toolBar->addWidget(_toolButtons[i]);
        ui->toolBar->addSeparator();
        _tool_items_nums[i].resize(head["models"].toInt());


        int index=0;            //小项目的编号
        for(int j=0;j<body.size();j++){

            QWidget* w=new QWidget(_toolBoxs[i]);

            _toolBoxs[i]->addWidget(body[j].first,w);
            QListWidget* listwidget=new QListWidget(w);
            listwidget->setMinimumHeight(200);

            _modelListWidget[i].push_back(listwidget);

            for(QString& label:body[j].second){
                QListWidgetItem* item=new QListWidgetItem(label);
                item->setData(Qt::UserRole,index++);
                listwidget->addItem(item);
                _tool_items[i].push_back(item);
                _tool_items_labels[i].push_back(label);
            }


            switch (Yzty::ToolCode(i)) {
                case Yzty::ToolCode::VirMachine:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->virmachinewidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                case Yzty::ToolCode::Security:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->securitywidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                case Yzty::ToolCode::Report:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->reportwidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                case Yzty::ToolCode::Normal:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->normalwidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                case Yzty::ToolCode::Email:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->emailwidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                case Yzty::ToolCode::File:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->filewidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                case Yzty::ToolCode::Deep:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->deepwidget->SetCurWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;

                case Yzty::ToolCode::Hard:
                    connect(listwidget,&QListWidget::clicked,[this](const QModelIndex& index){
                        ui->hardwidget->SetCurrentWidget(index.data(Qt::UserRole).toInt());
                    });
                    break;
                default:
                    break;
            }

            listwidget->setMinimumHeight(listwidget->sizeHintForRow(0)*listwidget->count()+10);

            listwidget->setContextMenuPolicy(Qt::CustomContextMenu);        //设置右键策略

            connect(listwidget,&QListWidget::customContextMenuRequested,[this,i,j](const QPoint& pos){
                this->Click_ListWidget_SingleCheck(i,j,pos);
            });

            QGridLayout* grid=new QGridLayout(w);
            grid->addWidget(listwidget);
            grid->setMargin(0);
            w->setLayout(grid);
        }

    }

    for(int i=0;i<models;i++){
        connect(_toolButtons[i],&QPushButton::clicked,[this,i](){
            ui->stackedWidget->setCurrentIndex(i);
        });
    }
    QList<QAction *>actionlist = ui->toolBar->actions();
    actionlist[12]->setVisible(false);//隐藏硬件检查按钮和分割线
    actionlist[13]->setVisible(false);
}

void MainWindow::CheckButton_CLick(Yzty::MODECODE code){
    ClearCheckFlag(code);
    FileInfor::GetInstance()->Resetcnts();
    if(_isrun[code]){
        int ret=QMessageBox::warning(this,"取消检查","正在运行中,是否取消?",QMessageBox::Yes|QMessageBox::No);
        if(ret==QMessageBox::Yes)
            EndingCheck(code);
        return;
    }
    if(code == (int)Yzty::ToolCode::Report) {           //运行检查报告
        if(!Checkreportdialog())//不符合检查条件
            return;
    }
    _isfinish[code]=false; //开始检查前设置检查完成标志为未完成
    if((!Yzty::FileCondtionFlag)&&(code==int(Yzty::ToolCode::Deep)||code==int(Yzty::ToolCode::File)))
        if(!FileCondtionDialog())   return;

    _times[code].setHMS(0,0,0);
    _checktools[code]->setText("取消检查");
    _isrun[code]=true;
    _timeids[code]=this->startTimer(1000);      //开启定时器
    this->_lcdtimes[code]->display("00:00");
    this->_processbars[code]->setValue(0);

    //设置检查标记
    for(int i=0;i<_tool_items_nums[code].size();i++)
        StartItemCheckFlag(code,i);

    switch(Yzty::ToolCode(code))
    {
        case Yzty::ToolCode::VirMachine:
            this->StartVirmachineCheck();
            break;
        case Yzty::ToolCode::Security:
            MainTool::GetInstance()->SetExeCuteToolCode(int(Yzty::ToolCode::Security),SecurityWidget::ShowTools);
            this->StartSecurityCheck();
            break;
        case Yzty::ToolCode::Report:
            this->StartReportCheck();
            break;
        case Yzty::ToolCode::Normal:
            MainTool::GetInstance()->SetExeCuteToolCode(int(Yzty::ToolCode::Normal),NormalWidget::ShowTools);
            this->StartNormalCheck();
            break;
        case Yzty::ToolCode::Email:
            this->StartEmailCheck();
            break;
        case Yzty::ToolCode::File:
            this->StartFileCheck();
           break;
        case Yzty::ToolCode::Deep:
            this->StartDeepCheck();
            break;
        case Yzty::ToolCode::Hard:
            MainTool::GetInstance()->SetExeCuteToolCode(int(Yzty::ToolCode::Hard),HardWidget::ShowTools);
            this->StartHardCheck();
            break;
        default:
            break;
    }
}

void MainWindow::StartNormalCheck(){
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::Normal));
}

void MainWindow::StartSecurityCheck(){
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::Security));
}

void MainWindow::StartFileCheck(){
    if(!Yzty::FileCondtionFlag){
        if(!this->FileCondtionDialog())
            return;
    }else
        InitFileCheckCondition();
    std::cout<<FileInfor::GetInstance()->GetFilecnts()<<std::endl;
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::File));
}

void MainWindow::StartDeepCheck(){
    if(!Yzty::DeepCondtionFlag)
        if(!this->DeepConditonDialog())
            return;
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::Deep));
}

void MainWindow::StartVirmachineCheck(){
    if(!Yzty::EmailCondionFlag)
        if(!this->EmailCondtionDialog())
            return;
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::VirMachine));
}

void MainWindow::StartEmailCheck(){
    if(!Yzty::EmailCondionFlag)
        if(!this->EmailCondtionDialog())
            return;
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::Email));
}

void MainWindow::StartHardCheck(){
    MainTool::GetInstance()->RunToolFunction(int(Yzty::ToolCode::Hard));
}

void MainWindow::EndingCheck(Yzty::MODECODE code){
    for(int i=0;i<_tool_items_nums[code].size();i++)
        FinishItemCheclFlag(code,i);

    _isrun[code]=false;
    _isfinish[code]=true;
    if(code == (int)Yzty::ToolCode::Hard) {
        std::cout << "硬件检查完成!" << std::endl;
    }

    this->_checktools[code]->setText("一键检查");
    this->killTimer(_timeids[code]);
    _timeids[code]=-1;
    _counts[size_t(code)]=0;
}

void MainWindow::AcceptFinish(Yzty::MODECODE mcode,Yzty::MODECODE tmcode,Yzty::MODECODE tcode){

    _counts[size_t(mcode)]++;   //计数器加一

    std::function<QVector<int>(const QVector<QSet<int>>&)> func=[mcode,tmcode,tcode,this](const QVector<QSet<int>>& maps)->QVector<int>{
        QVector<int> finish;
        for(int i=0;i<maps.size();i++){
            const QSet<int>& tools=maps[i];
            if(tools.contains(tmcode*Yzty::ToolMapItemHashCode+tcode)){
                this->_tool_items_nums[mcode][i]++;

                if(this->_tool_items_nums[mcode][i]==tools.size()){     //完成该项任务所有工作
                    if(!_isrun[mcode]&&i!=_current.data(Qt::UserRole).toInt())
                        continue;
                    this->FinishItemCheclFlag(mcode,i);
                    finish.push_back(i);
                }
            }
        }
        return finish;
    };

    QVector<int> finish;
     std::mutex   _mutex;
    switch(Yzty::ToolCode(mcode))
    {
        case Yzty::ToolCode::VirMachine:
            break;
        case Yzty::ToolCode::Security:
        {
            finish=func(SecurityWidget::ToolMapItem);
            for(int i:finish)
                ui->securitywidget->UpdateData(i);
            break;
        }
        case Yzty::ToolCode::Report:
            break;
        case Yzty::ToolCode::Normal:
            finish=func(NormalWidget::ToolMapItem);
            for(int i:finish)
                ui->normalwidget->UpdateData(i);
            break;
        case Yzty::ToolCode::Email:
            break;
        case Yzty::ToolCode::File:
 //           _mutex.lock();
 //           ui->filewidget->UpDatecnts();
//            _mutex.unlock();
            break;
        case Yzty::ToolCode::Deep:
            break;
        case Yzty::ToolCode::Hard:
            finish=func(HardWidget::ToolMapItem);
            for(int i:finish)
                ui->hardwidget->UpdateData(Yzty::HardToolCode(i));
            break;
        default:
            break;
    }


}

void MainWindow::ProgressMove(Yzty::MODECODE code){
    static int bace=10;
    int rest=100;
    int t=_counts[size_t(code)].load(),pt=_models[code];
    if(pt!=0)
        rest=t*100/pt- _processbars[code]->value();    //剩余进度

    if(rest>0){
        int step=rand()%qMin(bace,rest);
        if(pt==t)
            step=100-_processbars[code]->value();
        _processbars[code]->setValue(_processbars[code]->value()+step);
    }

    //如果检查完成结束检查
    if(_processbars[code]->value()==100){
        ui->filewidget->UpDatecnts();
        EndingCheck(code);
        return;
    }
}

void MainWindow::timerEvent(QTimerEvent *tevent){
    int id=tevent->timerId();
    for(int i=0;i<_timeids.size();i++){
        if(_timeids[i]==id){
            QTime temp=_times[i].addSecs(1);
            _lcdtimes[i]->display(temp.toString("mm:ss"));
            _times[i]=temp;
            ProgressMove(i);    //进度条推进
            if(i==int(Yzty::ToolCode::File)&&temp.second()%10==0)
                ui->filewidget->UpdateData(0);
        }
    }
}

bool MainWindow::FileCondtionDialog(){
    int ret=this->_filterdialog->exec();
    if(ret==1)
        InitFileCheckCondition();
    return ret==1;
}

bool MainWindow::EmailCondtionDialog(){
    int ret=this->_emaildialog->exec();
    if(ret==1)
        InitEmailCheckCondition();
    return ret==1;
}

bool MainWindow::VirCondtionDialog(){
    int ret=this->_virmachinedialog->exec();
    if(ret==1)
        InitVirCheckCondition();
    return ret==1;
}

bool MainWindow::DeepConditonDialog(){
    int ret=this->_deepdialog->exec();
    if(ret==1)
        InitDeepCheckCondition();
    return ret==1;
}

void MainWindow::InitFileCheckCondition(){
//    FileInfor::GetInstance()->Clear();
    FileTool::GetInstance()->SetOption("bkhash",1);
    Yzty::FileFilter::GetInstance()->SetFilterConditon(this->_filterdialog->GetFilterCondition());  //设置过滤条件
    FileTool::GetInstance()->SetFileCheckCondition(this->_filterdialog->GetFilterCondition());
    FileInfor::GetInstance()->SetFileCheckCondition(this->_filterdialog->GetFilterCondition());
    Yzty::FileCondtionFlag=true;
}

void MainWindow::InitEmailCheckCondition(){
    Yzty::EmailCondionFlag=true;
}

void MainWindow::InitVirCheckCondition(){
    Yzty::VirConditionFlag=true;
}

void MainWindow::InitDeepCheckCondition(){
    Yzty::DeepCondtionFlag=true;
}


void MainWindow::Init_StatusBar(int w){
    Yzty::StatusBarInfor infor=MainInfor::GetInstance()->GetStatusBarInfor();
    ui->statusbar->clearMessage();

    QLabel* temp=nullptr;
    temp=new QLabel(QString("版权所有:%1").arg(infor._corporation));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addWidget(temp,4);

    temp=new QLabel(QString("联系电话:%1").arg(infor._tel));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addWidget(temp,4);

    temp=new QLabel(QString("cpu:%1").arg(infor._cpu));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addWidget(temp,2);

    temp=new QLabel(QString("操作系统:%1").arg(infor._ostype));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addWidget(temp,2);

    temp=new QLabel(QString("网络:%1").arg(infor._netflag?"已连接":"未连接"));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addWidget(temp,2);

    temp=new QLabel(QString("密级:%1").arg(infor._levelpc==0?"公开":"保密"));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addWidget(temp,5);

    temp=new QLabel(QString("本机用户:%1").arg(infor._user));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addPermanentWidget(temp,2);

    temp=new QLabel(QString("ip地址:%1").arg(infor._ipaddres));
    temp->resize(w,ui->statusbar->height());
    ui->statusbar->addPermanentWidget(temp);

}

void MainWindow::ClearCheckFlag(int mcode){
    for(int i=0;i<_tool_items_nums[mcode].size();i++)
        _tool_items_nums[mcode][i]=0;
    _timeids[mcode]=-1;
    this->_lcdtimes[mcode]->display("00:00");
    this->_processbars[mcode]->setValue(0);
    _counts[size_t(mcode)]=0;

    for(int i=0;i<_tool_items_nums[mcode].size();i++){
        QFont font;
        font.setFamily("SimHei");
        _tool_items[mcode][i]->setText(_tool_items_labels[mcode][i]);
        _tool_items[mcode][i]->setFont(font);
        _tool_items[mcode][i]->setTextColor(QColor("black"));
    }
}

void MainWindow::StartItemCheckFlag(int mcode, int tcode){
    QString starttext("%1(正在检查)");
    starttext=starttext.arg(_tool_items_labels[mcode][tcode]);
    QFont font;
    font.setFamily("SimHei");
    _tool_items[mcode][tcode]->setText(starttext);
    _tool_items[mcode][tcode]->setFont(font);
    _tool_items[mcode][tcode]->setTextColor(QColor("red"));
}

void MainWindow::FinishItemCheclFlag(int mcode, int tcode){
    QString starttext("%1(检查完成)");
    starttext=starttext.arg(_tool_items_labels[mcode][tcode]);
    QFont font;
    font.setFamily("SimHei");
    _tool_items[mcode][tcode]->setText(starttext);
    _tool_items[mcode][tcode]->setFont(font);
    _tool_items[mcode][tcode]->setTextColor(QColor("green"));
}

void MainWindow::Click_ListWidget_SingleCheck(int mcode,int tcode,const QPoint& pos){
    QListWidget* lwidget=_modelListWidget[mcode][tcode];
    _current=lwidget->indexAt(pos);
    if(!_current.isValid())
        return;
    else if(mcode==int(Yzty::ToolCode::File)||_isrun[ui->stackedWidget->currentIndex()])
        for(QAction* temp:_ListWidgetActions)
            temp->setEnabled(false);
    else
        for(QAction* temp:_ListWidgetActions)
            temp->setEnabled(true);
    this->_ListWidgetMenu->exec(cursor().pos());
}

void MainWindow::SingleCheck(int mcode,int tcode){

    QList<int> toolcodes;

    switch(Yzty::ToolCode(mcode))
    {
        case Yzty::ToolCode::VirMachine:
            this->StartVirmachineCheck();
            break;
        case Yzty::ToolCode::Security:
 //           toolcodes=SecurityWidget::ToolMapItem[tcode].toList();
              toolcodes=SecurityWidget::ToolMapItem[tcode].values();
            break;
        case Yzty::ToolCode::Report:
            break;
        case Yzty::ToolCode::Normal:
 //           toolcodes=NormalWidget::ToolMapItem[tcode].toList();
              toolcodes=NormalWidget::ToolMapItem[tcode].values();
            break;
        case Yzty::ToolCode::Email:
            this->StartEmailCheck();
            break;
        case Yzty::ToolCode::File:
            this->StartFileCheck();
            break;
        case Yzty::ToolCode::Deep:
            this->StartDeepCheck();
            break;
        case Yzty::ToolCode::Hard:
//            toolcodes=HardWidget::ToolMapItem[tcode].toList();
            toolcodes=HardWidget::ToolMapItem[tcode].values();
            break;
        default:
            break;
    }

    for(int x:toolcodes){
        int pi=x/Yzty::ToolMapItemHashCode,pj=x%Yzty::ToolMapItemHashCode;
        this->StartItemCheckFlag(mcode,tcode);
      //  if(tcode==1)  pj=5;
        MainTool::GetInstance()->RunToolFunction(mcode,pi,pj);
    }

}

void MainWindow::StartReportCheck(){
    ReportTool::GetInstance()->GetReport();
}


bool MainWindow::Checkreportdialog() {
    reportdialogflag = reportconfigdialog.exec();
    if(!reportdialogflag)//如果没有填写信息
    {
        return false;
    }
    QStringList moduleinfor{
        "常规检查",
        "安全检查",
        "文件检查",
        "深度检查",
        "虚拟机检查",
        "邮箱检查",
        "硬件检查"
    };
    QString unfinish ="";
    for(int i=0;i<(int)Yzty::ToolCode::Total-1;i++) {
        if(!_isfinish[i]) {
            unfinish.push_back(moduleinfor[i]+',');
        }
    }
    if(unfinish!="")
        if(QMessageBox::warning(this,"未检查提示",QString("以下模块未检查\n\n%1\n\n是否继续").arg(unfinish),QMessageBox::Ok|QMessageBox::Cancel)==QMessageBox::Cancel)
            return false;
    return true;
}
